/*
 * @Author: 段本显
 * @Desc: 文件简介
 * @Date: 2021-09-15 11:07:06
 * @LastEditors: 段本显
 * @LastEditTime: 2021-09-15 14:22:42
 * @Email: duanbenxian@appiron.cn
 * @Mark: 如果有bug，那肯定不是我的锅，噜噜噜
 */
/**
 * Mock plugin for development and production.
 * https://github.com/anncwb/vite-plugin-mock
 */
import { viteMockServe } from 'vite-plugin-mock'

export function configMockPlugin(isBuild: boolean) {
  return viteMockServe({
    // ↓忽略以_开头的文件
    ignore: /^\_/,
    // ↓解析根目录下的mock文件夹
    localEnabled: !isBuild,
    prodEnabled: isBuild,
    mockPath: './src/mock',
    // supportTs: false,
    injectCode: `
       import { setupProdMockServer } from './mockProdServer';
       setupProdMockServer();
       `
  })
}
